<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props传入对象-父传子</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="./vue.js"></script>

</head>
<style>

</style>

<body>
    <h3>将post作为一个对象进行使用</h3><hr>
    <div id="app">
        <blog-post
        v-for="item in posts"
        v-bind:key="item.id"
        :post="item"     
        ></blog-post>
        <!-- v-bind:title="post.title"
        v-bind:content="post.content"    -->
    </div>
    <script>
        Vue.component("blog-post", {
            props: ['post'],//将post作为一个对象进行使用
            template: `
                <div class="blog-post">
                <h3>{{ post.title }}</h3>
                <div v-html="post.content"></div>
                <div v-html="post.publishedAt"></div>
                </div>
            `
        })
        const app = new Vue({
            el: '#app',
            data: {
                posts: [
                    { id: 1, title: '标题1' ,content:"111",publishedAt:'出版At',comments:'评论A'},
                    { id: 2, title: '神奇',content:'内容2' ,publishedAt:'出版At',comments:'评论A'},
                    { id: 3, title: 'Why Vue is so fun',content:'内容3',publishedAt:'出版At',comments:'评论A' }
                ],
            },
            methods: {

            },
        });
    </script> 
    <!-- <div id="app">
        <blog-post v-for="post in posts" :key="id" :post="post"></blog-post>
    </div>
    <script>
        Vue.component("blog-post", {
            props: ['post'],//将post作为一个对象进行使用
            template: `
                <div class="blog-post">
                <h3>{{ post.title }}</h3>
                <div v-html="post.content"></div>
                </div>
            `
        })
        const app = new Vue({
            el: '#app',
            data: {
                posts: [
                    { id: 1, title: '标题1' ,content:['111','222']},
                    { id: 2, title: '神奇',content:'内容2' },
                    { id: 3, title: 'Why Vue is so fun',content:'内容3' }
                ],
            },
            methods: {

            },
        });
    </script> -->
</body>

</html>